package com.fox.stock.config;


import com.fox.stock.pojo.vo.StockInfoConfig;
import com.fox.stock.utils.IdWorker;
import com.fox.stock.utils.ParserStockInfoUtil;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
@EnableConfigurationProperties({StockInfoConfig.class}) //开启对象相关配置对象的加载(就是将配置文件里配置的数据在bean注入之后把该类的属性先配置  TODO: 在没有bean注入该对象时直接用其中属性为空)
public class CommonConfig {

    /**
     * 配置雪花算法生成id的bean对象
     * @return
     */
    @Bean
    public IdWorker idWorker(){
        //基于运维人员对机房和机器的编号规划自行约定
        return new IdWorker(1L, 2L);
    }

    @Bean
    public ParserStockInfoUtil parserStockInfoUtil(){
        return new ParserStockInfoUtil(idWorker());
    }
}
